//
//  SegmentDownloader.m
//  SegmentDownloadDemo
//
//  Created by gao on 2018/5/30.
//  Copyright © 2018年 gao. All rights reserved.
//

#import "SegmentDownloader.h"
#import "SegmentDownloadSession.h"

@interface SegmentDownloader()


@end

@implementation SegmentDownloader
-(void)startDownloadSubTask:(SegmentDownloadTask_SubTask *)subTask{
    self.downloadSubTask = subTask;
    self.isWorking = YES;
    [SegmentDownloadSession startDownloadSubTask:subTask];
}
-(void)stopDownlod{

    self.downloadSubTask = nil;
    self.isWorking = NO;
}
-(BOOL)isWorking{
    if (self.downloadSubTask == nil || self.downloadSubTask.downloadTask == nil) {
        return NO;
    }
//    NSURLSessionTaskState state = self.downloadSubTask.downloadTask.state;
//    if (self.downloadSubTask.downloadTask.state == NSURLSessionTaskStateCompleted) {
//        return NO;
//    }

    return _isWorking;
}
-(NSString *)description{
    return [NSString stringWithFormat:@"downloadSubTask:%@ isWorking:%d",self.downloadSubTask,self.isWorking];
}


@end
